#!/usr/bin/env python3

import sys
import skrf
import matplotlib.pyplot as plt
skrf.stylely()

if len(sys.argv) != 2:
    print("Usage: %s network.s2p" % sys.argv[0], file=sys.stderr)
    exit(1)

network = skrf.Network(sys.argv[1])
network_dc = network.extrapolate_to_dc(kind='linear')

plt.figure()
mag = plt.subplot(2, 1, 1)
#mag = plt.subplot(1, 2, 1)
plt.title("Vector Network Analysis")
network_dc.s11.plot_s_db(color='b', label='')
phase = mag.twinx()
network_dc.s11.plot_s_deg(color='r', label='')

plt.subplot(2, 1, 2)
#plt.subplot(1, 2, 2)
plt.title("Time Domain Reflectometry")
network_dc.s11.plot_z_time_step(window='hamming', label="impedance")
plt.xlim((-0.5, 1.5))

plt.tight_layout()
plt.show()
